        const fs = require('fs')
        function mineReadFile(path){
            return new Promise((resolve,reject)=>{
                fs.readFile(path,(err,data)=>{
                if (err){
                    reject(err)
                }
                resolve(data.toString())
                })
            })
        }
        const createGenerator1 = function * (){
            yield 'success1'
            yield 'success2'
            yield 'success3'
        }
        const createGenerator2 = async function * (){
            yield await mineReadFile('./fs1.txt')
            yield 'success2'
            yield 'success3'
        }
        const main1 = () => {
            const generator = createGenerator1()
            for (const item of generator){
                console.log(item)
                
            }
            console.log('generator',generator[Symbol.iterator])
            console.log('generator',generator.next())
        }
        main1()
        //异步可迭代的
        //怎么遍历一个不可迭代的但是可以异步迭代的对象
        const main2 = async() => {
            const asyncgenerator = createGenerator2()
            console.log('asyncgenerator',asyncgenerator[Symbol.iterator])
            console.log('asyncgenerator',asyncgenerator.next())
            console.log('asyncgenerator',asyncgenerator)
            // for await(const item of asyncgenerator){
            //     console.log(item)
            // }
            //async/awai不能用then，await直接返回成功的回调函数

            var res = asyncgenerator.next()
            console.log(res)
        }
        main2()

